Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:13:01+00:00 2026-06-06T03:13:01+00:00

I want to do some CRC check in my own userspace programme. And I

  • 0

I want to do some CRC check in my own userspace programme. And I find that the kernel crypto lib is already in the system, and come with SSE4.2 support.

I tried to directly #include <linux/crc32c.h> and run gcc with -I/usr/src/linux/include/. However, it doesnot work.

Any way to use some kind of libcrc32c ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:13:02+00:00Added an answer on June 6, 2026 at 3:13 am

    You can use kernel crypto CRC32c (and other hash/cipher functions) from user-space via socket family AF_ALG on Linux:

    #include <unistd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <sys/socket.h>
    #include <linux/if_alg.h>
    #include <sys/param.h>
    #include <string.h>
    #include <strings.h>
    
    int
    main (int argc, char **argv) {
    
        int sds[2] = { -1, -1 };
    
        struct sockaddr_alg sa = {
            .salg_family = AF_ALG,
            .salg_type   = "hash",
            .salg_name   = "crc32c"
        };
    
        if ((sds[0] = socket(AF_ALG, SOCK_SEQPACKET, 0)) == -1 )
            return -1;
    
        if( bind(sds[0], (struct sockaddr *) &sa, sizeof(sa)) != 0 )
            return -1;
    
        if( (sds[1] = accept(sds[0], NULL, 0)) == -1 )
            return -1;
    
        char *s = "hello";
        size_t n = strlen(s);
        if (send(sds[1], s, n, MSG_MORE) != n)
            return -1;
    
        int crc32c = 0x00000000;
        if(read(sds[1], &crc32c, 4) != 4)
            return -1;
    
        printf("%08X\n", crc32c);
        return 0;
    }
    

    If you’re hashing files or socket data you can speed it up using zero-copy approach to avoid kernel -> user-space buffer copy with sendfile and/or splice.

    Happy coding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want some tutorials or some help from that i can get idea of
I want some javascript + ajax to check username availability on fly. And I
I want some tags to be added to an article. The problem is that
I want some application to look like widget inside my Python application. That's all.
I just want some kind of simple text overlay that shows for a few
I have some playing cards that flip over when you tap them. I want
I want some API's and some Document So that i can convert any file
I want some examples of C preprocessor directives, such as: #define pi 3.14 #define
I want some code to be triggered every second. Usually, I'd create a Timer
I want some of the goodies in a ListView, like being able to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.