mobile-shell / mobile-shell/mosh
Altivec code in `crypto/ocb_internal.cc` fails to compile, needs to use `__vector` instead of `vector`
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 14.5k
- Forks
- 865
- PR merge metrics
- No merged PRs in 30d
Description
Code in ocb_internal.cc is broken and fails to compile:
ocb_internal.cc:223:13: error: 'vector' does not name a type; did you mean 'vec_or'?
223 | typedef vector unsigned block;
| ^~~~~~
| vec_or
ocb_internal.cc:237:16: error: 'block' does not name a type
237 | static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
| ^~~~~
ocb_internal.cc:259:23: error: 'block' does not name a type
259 | static inline block double_block(block b) {
| ^~~~~
ocb_internal.cc:456:13: error: variable or field 'ecb_encrypt_blks' declared void
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~~~~~~~~~~~~
ocb_internal.cc:456:30: error: 'block' was not declared in this scope; did you mean 'clock'?
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~
| clock
ocb_internal.cc:456:37: error: 'blks' was not declared in this scope
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~
ocb_internal.cc:456:43: error: expected primary-expression before 'unsigned'
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~~~~
ocb_internal.cc:456:63: error: expected primary-expression before '*' token
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^
ocb_internal.cc:456:64: error: 'key' was not declared in this scope
456 | static void ecb_encrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~
ocb_internal.cc:463:13: error: variable or field 'ecb_decrypt_blks' declared void
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~~~~~~~~~~~~
ocb_internal.cc:463:30: error: 'block' was not declared in this scope; did you mean 'clock'?
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~
| clock
ocb_internal.cc:463:37: error: 'blks' was not declared in this scope
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~
ocb_internal.cc:463:43: error: expected primary-expression before 'unsigned'
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~~~~~~
ocb_internal.cc:463:63: error: expected primary-expression before '*' token
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^
ocb_internal.cc:463:64: error: 'key' was not declared in this scope
463 | static void ecb_decrypt_blks(block *blks, unsigned nblks, KEY *key) {
| ^~~
ocb_internal.cc:625:5: error: 'block' does not name a type
625 | block offset; /* Memory correct */
| ^~~~~
ocb_internal.cc:626:5: error: 'block' does not name a type
626 | block checksum; /* Memory correct */
| ^~~~~
ocb_internal.cc:627:5: error: 'block' does not name a type
627 | block Lstar; /* Memory correct */
| ^~~~~
ocb_internal.cc:628:5: error: 'block' does not name a type
628 | block Ldollar; /* Memory correct */
| ^~~~~
ocb_internal.cc:629:5: error: 'block' does not name a type
629 | block L[L_TABLE_SZ]; /* Memory correct */
| ^~~~~
ocb_internal.cc:630:5: error: 'block' does not name a type
630 | block ad_checksum; /* Memory correct */
| ^~~~~
ocb_internal.cc:631:5: error: 'block' does not name a type
631 | block ad_offset; /* Memory correct */
| ^~~~~
ocb_internal.cc:632:5: error: 'block' does not name a type
632 | block cached_Top; /* Memory correct */
| ^~~~~
ocb_internal.cc: In function 'int ae_init(ae_ctx*, const void*, int, int, int)':
ocb_internal.cc:692:5: error: 'block' was not declared in this scope; did you mean 'clock'?
692 | block tmp_blk;
| ^~~~~
| clock
ocb_internal.cc:708:10: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'cached_Top'
708 | ctx->cached_Top = ctx->ad_checksum = zero_block();
| ^~~~~~~~~~
ocb_internal.cc:708:28: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_checksum'
708 | ctx->cached_Top = ctx->ad_checksum = zero_block();
| ^~~~~~~~~~~
ocb_internal.cc:712:62: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'cached_Top'
712 | ocb_aes::encrypt(reinterpret_cast<unsigned char *>(&ctx->cached_Top),
| ^~~~~~~~~~
ocb_internal.cc:713:69: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'Lstar'
713 | reinterpret_cast<unsigned char *>(&ctx->Lstar), ctx->encrypt_key);
| ^~~~~
ocb_internal.cc:714:5: error: 'tmp_blk' was not declared in this scope
714 | tmp_blk = swap_if_le(ctx->Lstar);
| ^~~~~~~
ocb_internal.cc:714:31: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'Lstar'
714 | tmp_blk = swap_if_le(ctx->Lstar);
| ^~~~~
ocb_internal.cc:227:37: note: in definition of macro 'swap_if_le'
227 | #define swap_if_le(b) (b)
| ^
ocb_internal.cc:715:15: error: 'double_block' was not declared in this scope
715 | tmp_blk = double_block(tmp_blk);
| ^~~~~~~~~~~~
ocb_internal.cc:716:10: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'Ldollar'
716 | ctx->Ldollar = swap_if_le(tmp_blk);
| ^~~~~~~
ocb_internal.cc:718:10: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
718 | ctx->L[0] = swap_if_le(tmp_blk);
| ^
ocb_internal.cc:721:14: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
721 | ctx->L[i] = swap_if_le(tmp_blk);
| ^
ocb_internal.cc: At global scope:
ocb_internal.cc:735:8: error: 'block' does not name a type
735 | static block gen_offset_from_nonce(ae_ctx *ctx, const void *nonce)
| ^~~~~
ocb_internal.cc: In function 'void process_ad(ae_ctx*, const void*, int, int)':
ocb_internal.cc:763:50: error: 'block' does not name a type
763 | union { uint32_t u32[4]; uint8_t u8[16]; block bl; } tmp;
| ^~~~~
ocb_internal.cc:764:5: error: 'block' was not declared in this scope; did you mean 'clock'?
764 | block ad_offset, ad_checksum;
| ^~~~~
| clock
ocb_internal.cc:765:11: error: 'block' does not name a type
765 | const block * adp = (block *)ad;
| ^~~~~
ocb_internal.cc:768:5: error: 'ad_offset' was not declared in this scope
768 | ad_offset = ctx->ad_offset;
| ^~~~~~~~~
ocb_internal.cc:768:22: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_offset'
768 | ad_offset = ctx->ad_offset;
| ^~~~~~~~~
ocb_internal.cc:769:5: error: 'ad_checksum' was not declared in this scope
769 | ad_checksum = ctx->ad_checksum;
| ^~~~~~~~~~~
ocb_internal.cc:769:24: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_checksum'
769 | ad_checksum = ctx->ad_checksum;
| ^~~~~~~~~~~
ocb_internal.cc:774:30: error: expected ';' before 'ta'
774 | block ta[BPI], oa[BPI];
| ^~~
| ;
ocb_internal.cc:777:25: error: 'oa' was not declared in this scope
777 | oa[0] = xor_block(ad_offset, ctx->L[0]);
| ^~
ocb_internal.cc:777:59: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
777 | oa[0] = xor_block(ad_offset, ctx->L[0]);
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:778:25: error: 'ta' was not declared in this scope; did you mean 'tz'?
778 | ta[0] = xor_block(oa[0], adp[0]);
| ^~
| tz
ocb_internal.cc:778:50: error: 'adp' was not declared in this scope; did you mean 'ad'?
778 | ta[0] = xor_block(oa[0], adp[0]);
| ^~~
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:779:55: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
779 | oa[1] = xor_block(oa[0], ctx->L[1]);
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:781:59: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
781 | oa[2] = xor_block(ad_offset, ctx->L[1]);
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:648:34: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
648 | #define getL(_ctx, _tz) ((_ctx)->L[_tz])
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:784:62: note: in expansion of macro 'getL'
784 | ad_offset = xor_block(oa[2], getL(ctx, tz));
| ^~~~
ocb_internal.cc:798:34: error: 'ecb_encrypt_blks' is not a member of 'ocb_aes'
798 | ocb_aes::ecb_encrypt_blks(ta, BPI, ctx->encrypt_key);
| ^~~~~~~~~~~~~~~~
ocb_internal.cc:812:22: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_offset'
812 | ctx->ad_offset = ad_offset;
| ^~~~~~~~~
ocb_internal.cc:813:22: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_checksum'
813 | ctx->ad_checksum = ad_checksum;
| ^~~~~~~~~~~
ocb_internal.cc:817:22: error: expected ';' before 'ta'
817 | block ta[BPI];
| ^~~
| ;
ocb_internal.cc:838:71: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
838 | ad_offset = xor_block(ad_offset, ctx->L[0]);
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:839:33: error: 'ta' was not declared in this scope; did you mean 'tz'?
839 | ta[k] = xor_block(ad_offset, adp[k]);
| ^~
| tz
ocb_internal.cc:839:62: error: 'adp' was not declared in this scope; did you mean 'ad'?
839 | ta[k] = xor_block(ad_offset, adp[k]);
| ^~~
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:648:34: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
648 | #define getL(_ctx, _tz) ((_ctx)->L[_tz])
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:840:66: note: in expansion of macro 'getL'
840 | ad_offset = xor_block(ad_offset, getL(ctx, ntz(k+2)));
| ^~~~
ocb_internal.cc:846:71: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'L'
846 | ad_offset = xor_block(ad_offset, ctx->L[0]);
| ^
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:847:33: error: 'ta' was not declared in this scope; did you mean 'tz'?
847 | ta[k] = xor_block(ad_offset, adp[k]);
| ^~
| tz
ocb_internal.cc:847:62: error: 'adp' was not declared in this scope; did you mean 'ad'?
847 | ta[k] = xor_block(ad_offset, adp[k]);
| ^~~
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:852:70: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'Lstar'
852 | ad_offset = xor_block(ad_offset,ctx->Lstar);
| ^~~~~
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:853:37: error: 'union process_ad(ae_ctx*, const void*, int, int)::<unnamed>' has no member named 'bl'
853 | tmp.bl = zero_block();
| ^~
ocb_internal.cc:854:48: error: 'adp' was not declared in this scope; did you mean 'ad'?
854 | memcpy(tmp.u8, adp+k, remaining);
| ^~~
| ad
ocb_internal.cc:856:33: error: 'ta' was not declared in this scope; did you mean 'tz'?
856 | ta[k] = xor_block(ad_offset, tmp.bl);
| ^~
| tz
ocb_internal.cc:856:66: error: 'union process_ad(ae_ctx*, const void*, int, int)::<unnamed>' has no member named 'bl'
856 | ta[k] = xor_block(ad_offset, tmp.bl);
| ^~
ocb_internal.cc:224:46: note: in definition of macro 'xor_block'
224 | #define xor_block(x,y) vec_xor(x,y)
| ^
ocb_internal.cc:859:34: error: 'ecb_encrypt_blks' is not a member of 'ocb_aes'
859 | ocb_aes::ecb_encrypt_blks(ta, k, ctx->encrypt_key);
| ^~~~~~~~~~~~~~~~
ocb_internal.cc:859:51: error: 'ta' was not declared in this scope; did you mean 'tz'?
859 | ocb_aes::ecb_encrypt_blks(ta, k, ctx->encrypt_key);
| ^~
| tz
ocb_internal.cc:879:30: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_checksum'
879 | ctx->ad_checksum = ad_checksum;
| ^~~~~~~~~~~
ocb_internal.cc: In function 'int ae_encrypt(ae_ctx*, const void*, const void*, int, const void*, int, void*, void*, int)':
ocb_internal.cc:896:50: error: 'block' does not name a type
896 | union { uint32_t u32[4]; uint8_t u8[16]; block bl; } tmp;
| ^~~~~
ocb_internal.cc:897:5: error: 'block' was not declared in this scope; did you mean 'clock'?
897 | block offset, checksum;
| ^~~~~
| clock
ocb_internal.cc:899:19: error: 'ctp' was not declared in this scope; did you mean 'ctx'?
899 | block * ctp = (block *)ct;
| ^~~
| ctx
ocb_internal.cc:899:33: error: expected primary-expression before ')' token
899 | block * ctp = (block *)ct;
| ^
ocb_internal.cc:900:11: error: 'block' does not name a type
900 | const block * ptp = (block *)pt;
| ^~~~~
ocb_internal.cc:904:14: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'offset'
904 | ctx->offset = gen_offset_from_nonce(ctx, nonce);
| ^~~~~~
ocb_internal.cc:904:23: error: 'gen_offset_from_nonce' was not declared in this scope
904 | ctx->offset = gen_offset_from_nonce(ctx, nonce);
| ^~~~~~~~~~~~~~~~~~~~~
ocb_internal.cc:905:14: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_offset'
905 | ctx->ad_offset = ctx->checksum = zero_block();
| ^~~~~~~~~
ocb_internal.cc:905:31: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'checksum'
905 | ctx->ad_offset = ctx->checksum = zero_block();
| ^~~~~~~~
ocb_internal.cc:908:22: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'ad_checksum'
908 | ctx->ad_checksum = zero_block();
| ^~~~~~~~~~~
ocb_internal.cc:916:5: error: 'offset' was not declared in this scope; did you mean 'off_t'?
916 | offset = ctx->offset;
| ^~~~~~
| off_t
ocb_internal.cc:916:19: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'offset'
916 | offset = ctx->offset;
| ^~~~~~
ocb_internal.cc:917:5: error: 'checksum' was not declared in this scope
917 | checksum = ctx->checksum;
| ^~~~~~~~
ocb_internal.cc:917:22: error: 'ae_ctx' {aka 'struct _ae_ctx'} has no member named 'checksum'
917 | checksum = ctx->checksum;
| ^~~~~~~~
Same failure with gcc-4.2 and gcc-13.2.1.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crypto/ocb_internal.cc around the Altivec typedef near line 223, then review the subsequent block-related errors. Build the affected code on the relevant Altivec configuration; done means the file compiles without the reported vector and block errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100