ObjFW  Check-in [00246bf4bd]

Overview
Comment:Amiga library: Wrap OFPBKDF2 & OFScrypt
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amiga-library
Files: files | file ages | folders
SHA3-256: 00246bf4bd18a5e0de6e15fbddc662ef0147cc8b2a99fbd5a5c65b4378a519bf
User & Date: js on 2021-10-16 14:34:57
Other Links: branch diff | manifest | tags
Context
2022-10-18
22:17
Merge trunk into branch "amiga-library" check-in: ac19ed9d40 user: js tags: amiga-library
2021-10-16
14:34
Amiga library: Wrap OFPBKDF2 & OFScrypt check-in: 00246bf4bd user: js tags: amiga-library
12:41
src/amiga-linklib.xml: Fix typo check-in: e4ead87504 user: js tags: amiga-library
Changes

Modified src/amiga-funcarray.inc from [4661af4786] to [899fc541d1].

41
42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
41
42
43
44
45
46
47


48
49
50
51
52
53
54
55
56







-
-
+
+







(CONST_APTR)glue_OFHTTPStatusCodeString,
(CONST_APTR)glue_OFListItemNext,
(CONST_APTR)glue_OFListItemPrevious,
(CONST_APTR)glue_OFListItemObject,
(CONST_APTR)glue_OFSizeOfTypeEncoding,
(CONST_APTR)glue_OFAlignmentOfTypeEncoding,
(CONST_APTR)glue_OFOnce,
(CONST_APTR)glue_OFPBKDF2,
(CONST_APTR)glue_OFScrypt,
(CONST_APTR)glue_OFPBKDF2Wrapper,
(CONST_APTR)glue_OFScryptWrapper,
(CONST_APTR)glue_OFSalsa20_8Core,
(CONST_APTR)glue_OFScryptBlockMix,
(CONST_APTR)glue_OFScryptROMix,
(CONST_APTR)glue_OFSocketAddressParseIP,
(CONST_APTR)glue_OFSocketAddressParseIPv4,
(CONST_APTR)glue_OFSocketAddressParseIPv6,
(CONST_APTR)glue_OFSocketAddressMakeIPX,

Modified src/amiga-glue.h from [5f8aad8c81] to [04f469545c].

69
70
71
72
73
74
75
76
77


78
79
80
81
82
83
84
69
70
71
72
73
74
75


76
77
78
79
80
81
82
83
84







-
-
+
+







extern OFString *_Nonnull glue_OFHTTPStatusCodeString PPC_PARAMS(short code);
extern OFListItem _Nullable glue_OFListItemNext PPC_PARAMS(OFListItem _Nonnull listItem);
extern OFListItem _Nullable glue_OFListItemPrevious PPC_PARAMS(OFListItem _Nonnull listItem);
extern id _Nonnull glue_OFListItemObject PPC_PARAMS(OFListItem _Nonnull listItem);
extern size_t glue_OFSizeOfTypeEncoding PPC_PARAMS(const char *type);
extern size_t glue_OFAlignmentOfTypeEncoding PPC_PARAMS(const char *type);
extern void glue_OFOnce PPC_PARAMS(OFOnceControl *_Nonnull control, OFOnceFunction _Nonnull func);
extern void glue_OFPBKDF2 PPC_PARAMS(OFPBKDF2Parameters parameters);
extern void glue_OFScrypt PPC_PARAMS(OFScryptParameters parameters);
extern void glue_OFPBKDF2Wrapper PPC_PARAMS(const OFPBKDF2Parameters *_Nonnull parameters);
extern void glue_OFScryptWrapper PPC_PARAMS(const OFScryptParameters *_Nonnull parameters);
extern void glue_OFSalsa20_8Core PPC_PARAMS(uint32_t *_Nonnull buffer);
extern void glue_OFScryptBlockMix PPC_PARAMS(uint32_t *_Nonnull output, const uint32_t *_Nonnull input, size_t blockSize);
extern void glue_OFScryptROMix PPC_PARAMS(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp);
extern OFSocketAddress glue_OFSocketAddressParseIP PPC_PARAMS(OFString *IP, uint16_t port);
extern OFSocketAddress glue_OFSocketAddressParseIPv4 PPC_PARAMS(OFString *IP, uint16_t port);
extern OFSocketAddress glue_OFSocketAddressParseIPv6 PPC_PARAMS(OFString *IP, uint16_t port);
extern OFSocketAddress glue_OFSocketAddressMakeIPX PPC_PARAMS(const unsigned char *_Nonnull node, uint32_t network, uint16_t port);

Modified src/amiga-glue.m from [3a131dec1c] to [a85912ca13].

263
264
265
266
267
268
269
270

271
272

273
274

275
276
277
278

279
280

281
282

283
284
285
286
287
288
289
263
264
265
266
267
268
269

270
271

272
273

274
275
276
277

278
279

280
281

282
283
284
285
286
287
288
289







-
+

-
+

-
+



-
+

-
+

-
+







	M68K_ARG(OFOnceControl *_Nonnull, control, a0)
	M68K_ARG(OFOnceFunction _Nonnull, func, a1)

	OFOnce(control, func);
}

void __saveds
glue_OFPBKDF2 PPC_PARAMS(OFPBKDF2Parameters parameters)
glue_OFPBKDF2Wrapper PPC_PARAMS(const OFPBKDF2Parameters *_Nonnull parameters)
{
	M68K_ARG(OFPBKDF2Parameters, parameters, a0)
	M68K_ARG(const OFPBKDF2Parameters *_Nonnull, parameters, a0)

	OFPBKDF2(parameters);
	OFPBKDF2Wrapper(parameters);
}

void __saveds
glue_OFScrypt PPC_PARAMS(OFScryptParameters parameters)
glue_OFScryptWrapper PPC_PARAMS(const OFScryptParameters *_Nonnull parameters)
{
	M68K_ARG(OFScryptParameters, parameters, a0)
	M68K_ARG(const OFScryptParameters *_Nonnull, parameters, a0)

	OFScrypt(parameters);
	OFScryptWrapper(parameters);
}

void __saveds
glue_OFSalsa20_8Core PPC_PARAMS(uint32_t *_Nonnull buffer)
{
	M68K_ARG(uint32_t *_Nonnull, buffer, a0)

Modified src/amiga-library.h from [515dc680a7] to [2606f235ee].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+
+







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "macros.h"
#import "OFPBKDF2.h"
#import "OFScrypt.h"

#ifdef OF_MORPHOS
# include <ppcinline/macros.h>
# define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
#else
# define OF_M68K_ARG(type, name, reg)		\
	register type reg_##name __asm__(#reg);	\
93
94
95
96
97
98
99
100


101


95
96
97
98
99
100
101

102
103
104
105
106







-
+
+

+
+
	int (*_Nonnull atexit)(void (*_Nonnull)(void));
	OFSignalHandler _Nullable (*_Nonnull signal)(int, OFSignalHandler _Nullable);
	char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable);
	int (*_Nonnull _Unwind_Backtrace)(int (*_Nonnull)(void *_Nonnull,
	    void *_Null_unspecified), void *_Null_unspecified);
};

extern bool OFInit(unsigned int version, struct OFLibC *libC, FILE **sF);
extern bool OFInit(unsigned int version, struct OFLibC *_Nonnull libC,
    FILE *_Nonnull *_Nonnull sF);
extern unsigned long *OFHashSeedRef(void);
extern void OFPBKDF2Wrapper(const OFPBKDF2Parameters *_Nonnull parameters);
extern void OFScryptWrapper(const OFScryptParameters *_Nonnull parameters);

Modified src/amiga-library.m from [7e963b1641] to [439796746d].

634
635
636
637
638
639
640












641
642
643
644
645
646
647
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659







+
+
+
+
+
+
+
+
+
+
+
+







}

int
_Unwind_Backtrace(int (*callback)(void *, void *), void *data)
{
	return libC._Unwind_Backtrace(callback, data);
}

void
OFPBKDF2Wrapper(const OFPBKDF2Parameters *parameters)
{
	OFPBKDF2(*parameters);
}

void
OFScryptWrapper(const OFScryptParameters *parameters)
{
	OFScrypt(*parameters);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {
#ifdef OF_MORPHOS
	(CONST_APTR)FUNCARRAY_BEGIN,
	(CONST_APTR)FUNCARRAY_32BIT_NATIVE,

Modified src/amiga-library.xml from [99e036ac2d] to [90c4b86510].

99
100
101
102
103
104
105
106
107



108
109
110
111



112
113
114
115
116
117
118
99
100
101
102
103
104
105


106
107
108
109
110


111
112
113
114
115
116
117
118
119
120







-
-
+
+
+


-
-
+
+
+







  </function>
  <include>OFOnce.h</include>
  <function name='OFOnce'>
    <argument name='control' type='OFOnceControl *_Nonnull' m68k-reg='a0'/>
    <argument name='func' type='OFOnceFunction _Nonnull' m68k-reg='a1'/>
  </function>
  <include>OFPBKDF2.h</include>
  <function name='OFPBKDF2'>
    <argument name='parameters' type='OFPBKDF2Parameters' m68k-reg='a0'/>
  <function name='OFPBKDF2Wrapper'>
    <argument name='parameters' type='const OFPBKDF2Parameters *_Nonnull'
              m68k-reg='a0'/>
  </function>
  <include>OFScrypt.h</include>
  <function name='OFScrypt'>
    <argument name='parameters' type='OFScryptParameters' m68k-reg='a0'/>
  <function name='OFScryptWrapper'>
    <argument name='parameters' type='const OFScryptParameters *_Nonnull'
              m68k-reg='a0'/>
  </function>
  <!-- The following scrypt functions are only for tests. -->
  <function name='OFSalsa20_8Core'>
    <argument name='buffer' type='uint32_t *_Nonnull' m68k-reg='a0'/>
  </function>
  <function name='OFScryptBlockMix'>
    <argument name='output' type='uint32_t *_Nonnull' m68k-reg='a0'/>

Modified src/linklib/init.m from [63cadaa706] to [c206548e12].

396
397
398
399
400
401
402















396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}

DESTRUCTOR_P(ObjFW, 4000)
{
	dtor();
}
#endif

extern void OFPBKDF2Wrapper(const OFPBKDF2Parameters *parameters);
extern void OFScryptWrapper(const OFScryptParameters *parameters);

void
OFPBKDF2(OFPBKDF2Parameters *parameters)
{
	OFPBKDF2Wrapper(&parameters);
}

void
OFScrypt(OFScryptParameters *parameters)
{
	OFScryptWrapper(&parameters);
}

Modified src/linklib/linklib.m from [01f67f8836] to [f342855826].

544
545
546
547
548
549
550
551

552
553
554
555
556

557
558
559
560
561
562
563

564
565
566
567
568

569
570
571
572
573

574
575
576
577
578
579
580

581
582
583
584
585
586
587
544
545
546
547
548
549
550

551
552
553
554
555

556
557
558
559
560
561
562

563
564
565
566
567

568
569
570
571
572

573
574
575
576
577
578
579

580
581
582
583
584
585
586
587







-
+




-
+






-
+




-
+




-
+






-
+







	);

	__extension__ ((void (*)(OFOnceControl *_Nonnull, OFOnceFunction _Nonnull))*(void **)(((uintptr_t)ObjFWBase) - 202))(control, func);
#endif
}

void
OFPBKDF2(OFPBKDF2Parameters parameters)
OFPBKDF2Wrapper(const OFPBKDF2Parameters *_Nonnull parameters)
{
#if defined(OF_AMIGAOS_M68K)
	register struct Library *a6 __asm__("a6") = ObjFWBase;
	(void)a6;
	((void (*)(OFPBKDF2Parameters __asm__("a0")))(((uintptr_t)ObjFWBase) - 210))(parameters);
	((void (*)(const OFPBKDF2Parameters *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWBase) - 210))(parameters);
#elif defined(OF_MORPHOS)
	__asm__ __volatile__ (
	    "mr		%%r12, %0"
	    :: "r"(ObjFWBase) : "r12"
	);

	__extension__ ((void (*)(OFPBKDF2Parameters))*(void **)(((uintptr_t)ObjFWBase) - 208))(parameters);
	__extension__ ((void (*)(const OFPBKDF2Parameters *_Nonnull))*(void **)(((uintptr_t)ObjFWBase) - 208))(parameters);
#endif
}

void
OFScrypt(OFScryptParameters parameters)
OFScryptWrapper(const OFScryptParameters *_Nonnull parameters)
{
#if defined(OF_AMIGAOS_M68K)
	register struct Library *a6 __asm__("a6") = ObjFWBase;
	(void)a6;
	((void (*)(OFScryptParameters __asm__("a0")))(((uintptr_t)ObjFWBase) - 216))(parameters);
	((void (*)(const OFScryptParameters *_Nonnull __asm__("a0")))(((uintptr_t)ObjFWBase) - 216))(parameters);
#elif defined(OF_MORPHOS)
	__asm__ __volatile__ (
	    "mr		%%r12, %0"
	    :: "r"(ObjFWBase) : "r12"
	);

	__extension__ ((void (*)(OFScryptParameters))*(void **)(((uintptr_t)ObjFWBase) - 214))(parameters);
	__extension__ ((void (*)(const OFScryptParameters *_Nonnull))*(void **)(((uintptr_t)ObjFWBase) - 214))(parameters);
#endif
}

void
OFSalsa20_8Core(uint32_t *_Nonnull buffer)
{
#if defined(OF_AMIGAOS_M68K)