Use AlignedBuffer stedda posix_memalign(). Should work on PPC OS X 10.5.
Fixes #233 github issue.
This commit is contained in:
@@ -138,13 +138,9 @@ string Base64Key::printable_key( void ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Session::Session( Base64Key s_key )
|
Session::Session( Base64Key s_key )
|
||||||
: key( s_key ), ctx( NULL ), blocks_encrypted( 0 )
|
: key( s_key ), ctx_buf( ae_ctx_sizeof() ),
|
||||||
|
ctx( (ae_ctx *)ctx_buf.data() ), blocks_encrypted( 0 )
|
||||||
{
|
{
|
||||||
ctx = ae_allocate( NULL );
|
|
||||||
if ( ctx == NULL ) {
|
|
||||||
throw CryptoException( "Could not allocate AES-OCB context." );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( AE_SUCCESS != ae_init( ctx, key.data(), 16, 12, 16 ) ) {
|
if ( AE_SUCCESS != ae_init( ctx, key.data(), 16, 12, 16 ) ) {
|
||||||
throw CryptoException( "Could not initialize AES-OCB context." );
|
throw CryptoException( "Could not initialize AES-OCB context." );
|
||||||
}
|
}
|
||||||
@@ -155,8 +151,6 @@ Session::~Session()
|
|||||||
if ( ae_clear( ctx ) != AE_SUCCESS ) {
|
if ( ae_clear( ctx ) != AE_SUCCESS ) {
|
||||||
throw CryptoException( "Could not clear AES-OCB context." );
|
throw CryptoException( "Could not clear AES-OCB context." );
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_free( ctx );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Nonce::Nonce( uint64_t val )
|
Nonce::Nonce( uint64_t val )
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ namespace Crypto {
|
|||||||
class Session {
|
class Session {
|
||||||
private:
|
private:
|
||||||
Base64Key key;
|
Base64Key key;
|
||||||
|
AlignedBuffer ctx_buf;
|
||||||
ae_ctx *ctx;
|
ae_ctx *ctx;
|
||||||
uint64_t blocks_encrypted;
|
uint64_t blocks_encrypted;
|
||||||
|
|
||||||
|
|||||||
+1
-22
@@ -623,28 +623,7 @@ static block getL(const ae_ctx *ctx, unsigned tz)
|
|||||||
/* 32-bit SSE2 and Altivec systems need to be forced to allocate memory
|
/* 32-bit SSE2 and Altivec systems need to be forced to allocate memory
|
||||||
on 16-byte alignments. (I believe all major 64-bit systems do already.) */
|
on 16-byte alignments. (I believe all major 64-bit systems do already.) */
|
||||||
|
|
||||||
ae_ctx* ae_allocate(void *misc)
|
/* Mosh uses its own AlignedBuffer class, not ae_allocate() or ae_free(). */
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
(void) misc; /* misc unused in this implementation */
|
|
||||||
#if (__SSE2__ && !_M_X64 && !_M_AMD64 && !__amd64__)
|
|
||||||
p = _mm_malloc(sizeof(ae_ctx),16);
|
|
||||||
#elif (__ALTIVEC__ && !__PPC64__)
|
|
||||||
if (posix_memalign(&p,16,sizeof(ae_ctx)) != 0) p = NULL;
|
|
||||||
#else
|
|
||||||
p = malloc(sizeof(ae_ctx));
|
|
||||||
#endif
|
|
||||||
return (ae_ctx *)p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ae_free(ae_ctx *ctx)
|
|
||||||
{
|
|
||||||
#if (__SSE2__ && !_M_X64 && !_M_AMD64 && !__amd64__)
|
|
||||||
_mm_free(ctx);
|
|
||||||
#else
|
|
||||||
free(ctx);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user